package com.somsoft.handjc.activity.query.xzsp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.somsoft.handjc.activity.R;
import com.somsoft.handjc.activity.query.xuncha.ZhongHeQueryDetailActivity;
import com.somsoft.handjc.activity.query.xuncha.ZhongHeQueryFeedbackActivity;
import com.somsoft.handjc.util.BaseActivity;
import com.somsoft.handjc.util.MyApplication;
import com.somsoft.handjc.util.Utils;
import com.somsoft.handjc.util.XzspDataUtil;
import com.somsoft.handjc.util.XzzfDataUtil;

/**
 * 行政审批  详细页面
 * 
 * 
 */
@SuppressWarnings("all")
public class XzspDetailActivity extends BaseActivity {

	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyApplication.getInstance().addActivity(this);
		setTitle("业务信息明细");
		setContentView(R.layout.xzsp_jc_query_detail);
		try {
			Intent it = getIntent();
			final String ywlsh = it.getStringExtra("ywlsh");
			getData(ywlsh);
			
			Button btnShowJcInfo = (Button)findViewById(R.id.btnShowJcInfo); 
			btnShowJcInfo.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					Utils.openLoading(XzspDetailActivity.this);
					Intent it = new Intent(XzspDetailActivity.this,XzspDetailJcInfoActivity.class);
					it.putExtra("ywlsh", ywlsh);
					startActivity(it);
				}
			});
			Button btnShowBusinessInfo = (Button)findViewById(R.id.btnShowBusinessInfo); 
			btnShowBusinessInfo.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					Utils.openLoading(XzspDetailActivity.this);
					Intent it = new Intent(XzspDetailActivity.this,XzspQueryBusinessInfoMainActivity.class);
					it.putExtra("ywlsh", ywlsh);
					startActivity(it);
				}
			});
		} catch (Exception e) {
			Toast.makeText(XzspDetailActivity.this, "加载数据失败！", Toast.LENGTH_SHORT).show();
		}
		Utils.closeLoading();
	}
	
	private List<Map<String, Object>> getData(String ywlsh) throws Exception{
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("ywlsh",ywlsh));
		
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			JSONObject obj = XzspDataUtil.detailBase(params);
			Map<String, Object> map = new HashMap<String, Object>(); 
			String txt = "";
			txt += "部门名称："+obj.get("SLJGMC")+"\n";
			txt += "办理状态："+obj.get("BLZTMC")+"\n";
			txt += "审批事项名称："+obj.get("SPSXMC")+"\n";
			txt += "项目名称："+obj.get("XMMC")+"\n";
			txt += "受理时间："+obj.get("SHOULISJ")+"\n";
			txt += "业务办理时限：还有"+obj.get("LEAVINGSDAY")+"个工作日\n";
			txt += "业务流水号："+obj.get("YXTYWLSH")+"\n";
			txt += "已办的业务："+obj.get("overPosition")+"\n";
			
			((TextView)findViewById(R.id.ywlsh)).setText(obj.get("YWLSH").toString());
			((TextView)findViewById(R.id.commonDetail)).setText(txt);
			list.add(map);
		} catch (Exception e) {
			throw e;
		}
		return list;

	}


}
